<template>
    <div id="allmap"></div>
</template>
<script>
import BMap from 'BMap'
// import BMapLib from 'BMapLib'

export default {
  name: 'Map',
  data () {
    return {
      map: {}
      // indoorManager: {}
    }
  },
  methods: {
    /**
     * 初始化地图组件
     */
    initMap () {
      this.map = new BMap.Map('allmap') // 创建Map实例
      this.map.centerAndZoom(new BMap.Point(120.431249, 36.154512), 13) // 初始化地图,设置中心点坐标和地图级别
      this.map.setCurrentCity('青岛') // 设置地图显示的城市 此项是必须设置的
      this.map.enableScrollWheelZoom(true) // 开启鼠标滚轮缩放
      let mapNavigation = new BMap.NavigationControl() // 左上角，添加默认缩放平移控件
      // eslint-disable-next-line
      let mapControl = new BMap.ScaleControl({anchor: BMAP_ANCHOR_TOP_LEFT}) // 左上角，添加比例尺
      this.map.addControl(mapNavigation)
      this.map.addControl(mapControl)
      // let ss = new BMapLib.IndoorManager()
      // let im = new BMapLib.IndoorManager(this.map)
      // this.indoorManager = new BMapLib.IndoorManager(this.map) // 开启室内地图
      // this.indoorManager = im
      // if (ss === im) return
      this.$store.dispatch('createMap', this.map)
    }
  },
  mounted () {
    this.initMap()
  }
}
</script>

<!--Add"scoped" attribute to limit CSS to this component only -->
<style scoped>
#allmap{
  width: 100%; height: 100%;
}
</style>
